package com.zhao.wechat.exception;


import com.zhao.wechat.enums.StatusCodeEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import static com.zhao.wechat.enums.StatusCodeEnum.FAIL;


/**
 *  业务异常
 * @author: Stevezhao
 * @create: 2021-09-19 19:49
 */
@Getter
@AllArgsConstructor
public class BizException extends RuntimeException{

    /**
     * 状态码
    */
    private Integer code = FAIL.getCode();

    /**
     * 错误信息
    */
    private final String message;

    public BizException(String message){
        this.message = message;
    }

    public BizException(StatusCodeEnum statusCodeEnum){
        this.code = statusCodeEnum.getCode();
        this.message = statusCodeEnum.getDesc();
    }

}
